package cn.smbms.service.bill;

import cn.smbms.dao.bill.BillMapper;
import cn.smbms.pojo.Bill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class BillServiceImpl implements BillService{
    @Autowired
    private BillMapper billMapper;

    @Override
    public boolean add(Bill bill) throws Exception {
        boolean flag=false;
        if (billMapper.add(bill)>0){
            flag=true;
        }
        return flag;
    }

    @Override
    public List<Bill> getBillList(String productName, int providerId, int isPayment, int currentPageNo, int pageSize) throws Exception {
        currentPageNo = (currentPageNo-1)*pageSize;
        return billMapper.getBillList(productName, providerId,isPayment,currentPageNo, pageSize);
    }


    @Override
    public boolean deleteBillById(int id) throws Exception {
        boolean flag=false;
        if (billMapper.deleteBillById(id)>0){
            flag=true;
        }
        return flag;
    }

    @Override
    public Bill getBillById(int id) throws Exception {
        return billMapper.getBillById(id);
    }

    @Override
    public boolean modify(Bill bill) throws Exception {
        boolean flag=false;
        if (billMapper.modify(bill)>0){
            flag=true;
        }
        return flag;
    }

    @Override
    public int getBillCount(String productName, int providerId, int isPayment) throws Exception {
        return billMapper.getBillCount(productName,providerId,isPayment);
    }


}
